package com.cain.calendar.tool;

import android.app.Activity;
import android.content.SharedPreferences;

/**
 * Created by Cain on 2016/6/25.
 * 存放应用配置的静态类
 */
public class Configure {

    /**
     * 禁止构造实体类
     */
    private Configure() {

    }

    private static final String DATABASE_NAME = "calender";
    private static SharedPreferences preferences;   //全局轻量级数据库

    static {
        preferences = MyApplication.getContext().getSharedPreferences(DATABASE_NAME, Activity.MODE_PRIVATE);
    }

    /**
     * 存放int值
     * @param key
     * @param value
     */
    public static void putInt(String key, int value) {
        SharedPreferences.Editor editor = preferences.edit();
        editor.putInt(key, value);
        editor.commit();
    }

    /**
     * 获取int值
     * @param key
     * @param defValue
     * @return
     */
    public static int getInt(String key, int defValue) {
        return preferences.getInt(key, defValue);
    }
}
